﻿        <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ReportForm.ascx.cs" Inherits="UserControl_Report_Form" %>
        <script type="text/javascript">
            function PrintNew() {
                var disp_setting = "toolbar=yes,location=yes,directories=yes,menubar=yes,";
                disp_setting += "scrollbars=yes";
                var content_vlue = document.getElementById("gc_gobal_ListDataID").innerHTML;

                var docprint = window.open("", "", 'width=600,height=500');
                docprint.document.open();
                docprint.document.write('<html><head><link href="../Usercontrol/style_home.css" rel="stylesheet" type="text/css" /> ');
                //docprint.document.write('<script language="javascript" type="text/javascript">');
                //docprint.document.write('function Button2_onclick() {var btnIn=window.document.getElementById("btnInPhieu"); btnIn.style.visibility="hidden";  print();}');
                //docprint.document.write('<//script>');
                docprint.document.write('</head><body onLoad="window.print()"><center>');

                docprint.document.write(content_vlue);
                docprint.document.write('</center></body></html>');
                docprint.document.close();
                docprint.focus();
                
            }
            $(window).load(function () {

                $("#dp2").val(XDate.today().toString("dd/MM/yyyy"));
                $("#dp1").val(XDate.today().toString("dd/MM/yyyy"));
            });

            $(document).ready(function () {
                $("#gcReportCreateID").click(function (ev) {
                    var dataString = "valve";
                    $("#gc_gbHTitle").html("Báo cáo doanh thu");
                    $('#gc_gb_MessageInfomation').html("<img src='../UserControl/Images/loading.gif'/>&nbsp;<strong>Đang tải dữ liệu...</strong> Bạn không nên đóng trình duyệt trong lúc này.");
                    $("#gc_gobal_PagerTopID").hide();
                    $("#gc_ClassInformationInnerID").html("");
                    $("#gc_gobal_ListDataID").html("");

                    var idLopHoc = $("#gc_cmbLopHocID" + "_ID").val();

                    if ($("#gc_cmbLopHocID").val().length <= 0)
                        idLopHoc = "";

                    var value = $("#" + cur_gb_CotrolID + "_ID").val();
                    if (value == '5')
                        $("#gc_gbHTitle").html("Bảng điểm học viên");
                    if (value == '2' || value == '3')
                        $("#gc_gbHTitle").html("Danh sách học viên");

                    if (value == '4')
                        $("#gc_gbHTitle").html("LỊCH HỌC CÁC LỚP TRONG TUẦN");

                    var codei = $("#gcCodeSearchReport").val();
                    var ti1 = gcDateC($("#dp1").val());
                    var ti2 = gcDateC($("#dp2").val());

                    $.ajax({
                        type: "POST",
                        url: "../ReportHandler.ashx",
                        data: { v1: value, v2: idLopHoc, t1: ti1, t2: ti2, code: codei },
                        //data: "{ 'v1': '" + value + "', 'v2': '" + idLopHoc + "' , 't1': '" + t1 + "', 't2': '" + t2 + "'}",
                        //contentType: "application/json; charset=utf-8",
                        //dataType: "json",
                        success: function (msg) {
                            $("#gc_gobal_ListDataID").html(msg);
                            $('#gc_gb_MessageInfomation').html("<i class='glyphicon glyphicon-ok '></i>&nbsp;<strong>Đã tải dữ liệu thành công.</strong> ");
                        },
                        error: function (xhr, ErrorText, thrownError) {
                            $("#gc_gobal_ListDataID").text("Error" + xhr.status + xhr.responseText);
                        }

                    });
                    return false;
                });

                /*For testing */
                $("#gc_BtnSearchCancelBtnID").click(function (ev) {//only testing get webmethod from aspx.
                    var dataString = "valve";
                    $("#gc_gbHTitle").html("Kết quả tìm kiếm");
                    $("#gc_gobal_PagerTopID").hide();
                    $("#gc_ClassInformationInnerID").html("");
                    $("#gc_gobal_ListDataID").html("");
                    $.ajax({
                        type: "POST",
                        url: "ClassInfo.aspx/GetCurrentTime",
                        data: "{ 'name': '9' }",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            $("#gc_gobal_ListDataID").html(msg.d);
                            $('#gc_gb_MessageInfomation').html("<i class='glyphicon-ok '></i>&nbsp;<strong>Kết quả tìm kiếm.</strong> ");
                        },
                        error: function (xhr, ErrorText, thrownError) {
                            $("#gc_gobal_ListDataID").text("Error" + xhr.status + xhr.responseText);
                        }

                    });
                    return false;
                });

                $("#gcReportPrintID").click(function (ev) {
                    PrintNew();
                });


                $("#gc_gb_ExportToExecl").click(function (ev) {
                    var data = $("#gc_gobal_ListDataID").html();
                    data = encodeURIComponent(data);
                    $('body').prepend("<form method='post' action='../exportPage.aspx' style='top:-3333333333px;' id='tempForm'><input type='hidden' name='data' value='" + data + "' ></form>");
                    $('#tempForm').submit();
                    $("tempForm").remove();
                    return false;
                });
            });

         </script>

        <!-- gc Report Information : first time is disable-->
        <div class="content gc-gb-notshowatInit" id="gc_ReportForm">
            <div id='gc_ReportFormInner' class="gc_SearchForm" >
	           <div class="login_sign" id="Div8">
                    <div class="input">
                        <label>Từ ngày</label>
                        <input type="text"  autocomplete="off" value="10/10/2013" id="dp1" name='datepicker' />

                        <label>đến ngày</label>
                        <input type="text"  autocomplete="off" value="11/10/2013" id="dp2" name='datepicker' />

                        <label>Chọn báo cáo</label>
                        <input type="text" autocomplete="off"   value="Chọn danh sách..." id="gcReportTypeID" name="combo" class="input-large gc-style-input-large200"  />
                        <input type="text" id="gcReportTypeID_ID" style='display:none;'  />

                        <label>Mã</label>
                        <input type="text"  autocomplete="off" value="" id="gcCodeSearchReport"  style="width:80px" />
                    </div>
                </div>
                <div class="inputBtnBottomV2">
                        <input type="button"  value="Tạo báo cáo" id="gcReportCreateID"  class="btn btn-primary btn-sm" />
                        <input type="button"  value="Lưu file Excel" id="gc_gb_ExportToExecl"  class="btn btn-info btn-sm" />
                         <input type="button"  value="Print" id="gcReportPrintID"  class="btn btn-info btn-sm" />
                 </div>
            </div>
        </div>
        <!-- End gc Report Information -->